package ${actionPackage};

import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import ${servicePackage}.${pojo.getDeclarationName()}Service;
import ${clazz.entityName};

public class ${pojo.getDeclarationName()}Action{
	private static final Log log = LogFactory.getLog(${pojo.getDeclarationName()}Action.class);

	private ${pojo.getDeclarationName()}Service ${pojo.getDeclarationName()?uncap_first}Service = null;
	public void set${pojo.getDeclarationName()}Service(${pojo.getDeclarationName()}Service ${pojo.getDeclarationName()?uncap_first}Service){
		this.${pojo.getDeclarationName()?uncap_first}Service=${pojo.getDeclarationName()?uncap_first}Service;
	}
	public ${pojo.getDeclarationName()}Service get${pojo.getDeclarationName()}Service(){
		return ${pojo.getDeclarationName()?uncap_first}Service;
	}
	
	private ${pojo.getDeclarationName()} ${pojo.getDeclarationName()?uncap_first} = new ${pojo.getDeclarationName()}();
	public void set${pojo.getDeclarationName()}(${pojo.getDeclarationName()} ${pojo.getDeclarationName()?uncap_first}){
		this.${pojo.getDeclarationName()?uncap_first}=${pojo.getDeclarationName()?uncap_first};
	}
	public ${pojo.getDeclarationName()} get${pojo.getDeclarationName()}(){
		return ${pojo.getDeclarationName()?uncap_first};
	}
	
	private List list = null;
	public List getList() {
		return list;
	}
	public void setList(List list) {
		this.list = list;
	}
	// CRUD create retrieve update delete
	
	public String create() {
		String result = "";
		log.debug("create ${pojo.getDeclarationName()} instance");
		${pojo.getDeclarationName()?uncap_first}Service.create(${pojo.getDeclarationName()?uncap_first});
		result = "createSuccess";
		return result;
	};

	public String retrieve() {
		String result = "";
		log.debug("retrieve ${pojo.getDeclarationName()} instance");
		${pojo.getDeclarationName()?uncap_first} = ${pojo.getDeclarationName()?uncap_first}Service.retrieve(${pojo.getDeclarationName()?uncap_first}.getId());
		result = "retrieveSuccess";
		return result;
	};
	
	public String retrieveAll() {
		String result = "";
		log.debug("retrieveAll ${pojo.getDeclarationName()} instance");
		list = ${pojo.getDeclarationName()?uncap_first}Service.retrieve();
		result = "retrieveAllSuccess";
		return result;
	};

	public String delete() {
		String result = "";
		log.debug("delete ${pojo.getDeclarationName()} instance");
		${pojo.getDeclarationName()?uncap_first}Service.delete(${pojo.getDeclarationName()?uncap_first}.getId());
		result = "deleteSuccess";
		return result;
	};
	
	public String update() {
		String result = "";
		log.debug("update ${pojo.getDeclarationName()} instance");
		${pojo.getDeclarationName()?uncap_first}Service.update(${pojo.getDeclarationName()?uncap_first});
		result = "updateSuccess";
		return result;
	};
}